package com.example.springmvc.controller;

import com.example.springmvc.pojo.User;
import com.example.springmvc.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    
    @Autowired
    private IUserService userService;

    @RequestMapping("/list")
    public String list(Model m) {
        List<User> users = userService.queryList();
        m.addAttribute("users", users);
        return "user/list";
    }

    @RequestMapping("/login")
    public String login()
    {
        return "/user/login";
    }

    @RequestMapping("/loginchk")
    public String loginchk(String username, String password, HttpSession session)
    {
        System.out.println("username:"+username);

        session.setAttribute("username",username);

        return "redirect:/item/itemList2";
    }



}
